<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        const str = '12:12:21,13:40:30';

        // console.log(str.replace(/(\d{2}):(\d{2}):(\d{2})/g, '$1$2$3'));
        console.log(str.replace(/(?<h>\d{2}):(?<m>\d{2}):(?<s>\d{2})/g, '$<h>时$<m>分$<s>秒'));




    </script>
</body>

</html>